<?php


namespace App\HttpController;


use EasySwoole\Http\AbstractInterface\Controller;
use EasySwoole\Http\Message\Status;

class Frameset extends \App\Base\AuthController
{

    public function __construct()
    {
        parent::__construct();
    }



    public function index(){
        
        $queryBuild=new \EasySwoole\Mysqli\QueryBuilder();
        $queryBuild->raw("select VERSION() as version");
        $data=\EasySwoole\Orm\DbManager::getInstance()->query($queryBuild, true)->getResult();
        $mysql_version=$data[0]['version'];
        $this->fetch(__FUNCTION__,['mysql_version'=>$mysql_version]);
    }

    public function logout(){
        $this->session()->start();
        $this->session()->destroy();
        $this->response()->setCookie('ESSession','',time()-3600);
        $this->response()->redirect("/welcome/login");
    }
    public function set_menu_current(){
        $request=$this->request();
        $post = $request->getParsedBody();
        $this->session()->set('open_sidebar_menu',$post['a']);
        $this->session()->set('open_sidebar_item',$post['href']);
        $this->writeJson(Status::CODE_OK, time(), 'success');
    }
    public function get_menu_current(){
        $a=$this->session()->get('open_sidebar_menu');
        if(!$a) $a=0;
        $href=$this->session()->get('open_sidebar_item');
        if(!$href) $href='#';
        $this->writeJson(Status::CODE_OK, ['a'=>$a,'href'=>$href], 'success');
    }
}